package ui.view;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.GridLayout;
import java.util.Vector;

import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JPanel;

import automatica.datamining.RelationMining.RelationTriple;

public class CheckBox extends JPanel{
	public CheckBox(){
		this.setLayout(new GridLayout(0, 1));	
	}
	
	public CheckBox(Vector<RelationTriple> relationObjects){
		this();
		this.relationObjects = relationObjects;
		for(int i = 0; i < relationObjects.size(); i++){
			JCheckBox buffer = new JCheckBox(relationObjects.get(i).toString(),false);
			buffer.setFont(constants.GTextbookConstants.Relation_Check_Font);
			this.add(buffer);
		}
		
	}
	
	
	public Vector<RelationTriple> getSelectedRelations(){
		Vector<RelationTriple> selectedRelations = new Vector<RelationTriple>(1,1);
		Component[] selected = this.getComponents();
		for(int i = 0 ; i < selected.length; i++){
			if(((JCheckBox)selected[i]).getSelectedObjects()!=null){
				String selectString = ((JCheckBox)selected[i]).getSelectedObjects()[0].toString();
				for(int j = 0; j < relationObjects.size(); j++){
					if(relationObjects.get(j).toString().equals(selectString)){
						selectedRelations.add(relationObjects.get(j));
						System.out.println(relationObjects.get(j));
					}
				}
			}
			
		}
		
		
		
		return selectedRelations;
	}
	
	
	Vector<RelationTriple> selectedRelations = new Vector<RelationTriple>(1,1);
	
	
	
	Vector<RelationTriple> relationObjects = new Vector<RelationTriple>(1,1);
	
	
	
}
